<template>
 <div class="sex1">
  <div class="top">
    <p class="title">男女比例</p>
    <p class="bg"></p>
  </div>
  <div class="sex-box">
    <div class="man">
      <img src="../../images/man.png" alt="">
    </div>
    <div class="woman">
      <img src="../../images/woman.png" alt="">
    </div>
  </div>
  <div class="rate">
    <p>男士58%</p>
    <p>女士42%</p>
  </div>
  <div class="charts" ref="charts"></div>
</div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

const charts = ref()

onMounted(()=>{
  const myCharts = echarts.init(charts.value)
  myCharts.setOption({

    xAxis: {
      show: false,
      min:0,
      max:100
    },
    yAxis: {
      show: false,
      type: 'category',
    },
    series: [
      {
        type: 'bar',
        data: [58],
        barWidth: 20,
        z:99,
        itemStyle: {
          borderRadius: 20
        }
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        //调整女士bar的位置
        barGap: '-100%',
        itemStyle: {
          color: 'pink',
          borderRadius: 20
        }
      }
    ],
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0
    }
  })
})




</script>

<style lang="scss" scoped>
  .sex1 {
    width: 100%;
    height: 100%;
    background: url(../../images/dataScreen-main-lb.png) no-repeat;
    background-size: 100% 100%;
    .top {
      font-size: 20px;
      color: #fff;
      .title {
        margin-left: 20px;
        margin-bottom: 10px;
        margin-top: 10px;
      }
      .bg {
        background: url(../../images/dataScreen-title.png) no-repeat;
        background-size: 100% 100%;
        width: 68px;
        height: 7px;
        margin-left: 20px;
        
      }
      .txt-right {
        text-align: right;
        margin-right: 20px;
        span {
          color: yellowgreen;
        }
      }
    }
    .sex-box {
      display: flex;
      justify-content: center;
      margin-top: 5px;
      .man {
        margin: 10px;
        background: url(../../images/man-bg.png) no-repeat;
        width: 111px;
        height: 110px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .woman {
        margin: 10px;
        background: url(../../images/woman-bg.png) no-repeat;
        width: 111px;
        height: 110px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
    .rate {
      display: flex;
      justify-content: space-between;
      color: #fff;
      width: 80%;
      margin: 0 auto;
      position: relative;
      top: 10px;
    }
    .charts {
      width: 80%;
      height: 100px;
      margin: 0 auto;
    }
  }
</style>
